package top.yuzt.animalserver.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.yuzt.animalserver.common.GiteeService;

import java.io.IOException;

@RestController
public class GiteeController {

    @Autowired
    private GiteeService giteeService;

    @GetMapping("/api/commits")
    public String getCommits(@RequestParam String owner, @RequestParam String repo, @RequestParam String token) {
        try {
            return giteeService.getCommits(owner, repo, token);
        } catch (IOException e) {
            return "Error: " + e.getMessage();
        }
    }
}
